package pl.puntin.punclient.messages;

import java.util.HashMap;


/**
 * Singleton z leniwa inicalizacja
 * @author kakus
 *
 */
public class MessageTypesMap
{
	private static HashMap<Byte, Class<? extends Message>> typesMap;
	
	private static void initMapTypes()
	{
		typesMap = new HashMap<Byte, Class<? extends Message>>();
		
		/**
		 * Rejestracja
		 */
		typesMap.put(MessageTypes.CHECK_CONNECTION, CheckConnectionMessage.class);
		typesMap.put(MessageTypes.CHAT_MESSAGE, ChatMessage.class);
		typesMap.put(MessageTypes.IMAGE_MESSAGE, ImageMessage.class);
		typesMap.put(MessageTypes.S_LOGIN_OK, LoginOkMessage.class);
		typesMap.put(MessageTypes.S_LOGIN_FALSE, LoginFalseMessage.class);
		typesMap.put(MessageTypes.S_ROOM_LIST, RoomListMessage.class);
		typesMap.put(MessageTypes.S_ADD_ROOM_OK, AddRoomOkMessage.class);
		typesMap.put(MessageTypes.S_ADD_ROOM_FALSE, AddRoomFalseMessage.class);
		typesMap.put(MessageTypes.S_JOIN_ROOM_OK, JoinRoomOkMessage.class);
		typesMap.put(MessageTypes.S_JOIN_ROOM_FALSE, NotJoinRoomMessage.class);
		typesMap.put(MessageTypes.S_START_NEW_GAME_OK, StartNewGameOkMessage.class);
		typesMap.put(MessageTypes.S_PUN_FOR_DRAWER, PunForDrawerMessage.class);
		typesMap.put(MessageTypes.S_DRAWER_PASSED, DrawerPassesMassege.class);
/*		typesMap.put(MessageTypes.S_DRAWER_LOGOUT);
		typesMap.put(MessageTypes.S_SOMEONE_GUESSED);
		typesMap.put(MessageTypes.S_ROUND_TIMEOUT);						
		typesMap.put(MessageTypes.S_PLAYER_LOGIN);
		typesMap.put(MessageTypes.S_UPDATE_RANKING);
		typesMap.put(MessageTypes.S_FOREVER_ALONE);
		typesMap.put(MessageTypes.S_PLAYER_LOGOUT);
		typesMap.put(MessageTypes.S_END_OF_GAME_WINNER);
		typesMap.put(MessageTypes.S_END_OF_GAME);
*/		typesMap.put(MessageTypes.C_ROOM_LIST, RoomListPleaseMessage.class );
		typesMap.put(MessageTypes.C_CREATE_ROOM, CreateRoomMessage.class);
		typesMap.put(MessageTypes.C_JOIN_ROOM, JoinRoomMessage.class);
		typesMap.put(MessageTypes.C_LOGIN, LoginMessage.class);
		typesMap.put(MessageTypes.C_START_NEW_GAME, StartNewGame.class);
//		typesMap.put(MessageTypes.C_LEAVE_ROOM,);
//		typesMap.put(MessageTypes.C_LOGOUT,);
//		typesMap.put(MessageTypes.C_GIVE_UP, );

	}
	
	public static Class<? extends Message> getClass(final byte code)
	{
		if(typesMap == null)
			initMapTypes();
		
		return typesMap.get(code);
	}
}

